﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zoo.Cat.Domain.Unity;
using Zoo.Cat.Domain.Entities.Lovs;
using Zoo.Infrastructure.Data.Core;
using Zoo.Infrastructure.Caching;
using Zoo.Infrastructure.Events;

namespace Zoo.Cat.Application.Lovs
{
    public class LovService : ILovService
    {
        #region Fields
        private readonly IRepository<Lov> _lovRepository;
        private readonly ICacheManager _cacheManager;
        private readonly IEventPublisher _eventPublisher;
        #endregion

        #region Ctor
        public LovService(IRepository<Lov> lovRepository,
            ICacheManager cacheManager, IEventPublisher eventPublisher)
        {
            this._cacheManager = cacheManager;
            this._eventPublisher = eventPublisher;
            this._lovRepository = lovRepository;
        }
        #endregion

        #region Method
        public Lov GetById(Guid id)
        {
            return _lovRepository.GetById(id);
        }

        public IQueryable<Lov> GetLovInfoList(IEnumerable<int> valueList)
        {
            IQueryable<Lov> lovList = from lov in _lovRepository.Table
                                      where valueList.Contains(lov.Value)
                                      select lov;
            return lovList;
        }

        public IQueryable<Lov> GetLovInfoList(IEnumerable<Guid> idList)
        {
            IQueryable<Lov> lovList = from lov in _lovRepository.Table
                                      where idList.Contains(lov.Id)
                                      select lov;
            return lovList;
        } 
        #endregion
    }
}
